#include "ht_room.h"

int main(int argc,const char* argv[])
{
	Room* room = new Room[100];
	ifstream ifs("room.txt");
	if(!ifs.is_open())
	{
		cout << "读取信息错误!" << endl;
		return -1;
	}
	Room* dest = room;
	while(ifs.good())
	{
		int roomid;
		int rmt;
		float price;
		int mem;
		string pname;
		string psex;
		string pid;
		ifs >> roomid >> rmt >> price >> mem;
		dest->setRoomId(roomid);
		dest->setRoomType((RoomType)rmt);
		dest->setRoomPrice(price);
		dest->setRoomStatus(mem);
		for(int i=0;i<dest->getRoomStatus();i++)
		{
			ifs >> pname >> psex >> pid;
			dest->setRoomGuest(pname,psex,pid,i);
		}
		dest++;
	}
	room->help();
	room->displayAllRoom(room,All);
	ifs.close();
	ofstream ofs("room.txt");
	if(!ofs.is_open())
	{
		cout << "数据保存失败!" << endl;
		return -1;
	}
	for(int i=0;i<100;i++)
	{
		ofs << room[i].getRoomId() <<" "<< (int)room[i].getRoomType() << " " << room[i].getRoomPrice() << " " << room[i].getRoomStatus() << endl;
		for(int j=0;j<room[i].getRoomStatus();j++)
		{
			ofs << room[i].getRoomGuest()[j].getName() << " " << room[i].getRoomGuest()[j].getSex() << " " << room[i].getRoomGuest()[j].getId() << endl;	
		}
	}
	ofs.close();
	delete[] room;
}
